package com.atguigu.lease.common.context;


/**
 * 定义一个登录用户上下文类，里面创建了本地线程对象
 */
public class LoginUserContext {
    public static final ThreadLocal<LoginUser> loginUserThreadLocal = new ThreadLocal<>();

    //设置登录用户信息
    public static void setLoginUser(LoginUser loginUser){
        loginUserThreadLocal.set(loginUser);
    }

    //通过本地线程对象获取登录用户信息
    public static LoginUser getLoginUser(){
        return loginUserThreadLocal.get();
    }
    public static void clear() {
        loginUserThreadLocal.remove();
    }
}
